package com.virtualperson.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class VideoGenerationResponse {
    @JsonProperty("request_id")
    private String requestId;
    
    private Output output;
    
    private Usage usage;

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Output {
        @JsonProperty("task_id")
        private String taskId;
        
        @JsonProperty("task_status")
        private String taskStatus;
        
        private Results results;
        
        private String code;    // 错误码
        private String message; // 错误信息
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Results {
        @JsonProperty("video_url")
        private String videoUrl;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Usage {
        @JsonProperty("video_duration")
        private Float videoDuration;
        
        @JsonProperty("video_ratio")
        private String videoRatio;
    }

    // 任务状态常量
    public static final String STATUS_PENDING = "PENDING";    // 排队中
    public static final String STATUS_RUNNING = "RUNNING";    // 处理中
    public static final String STATUS_SUCCEEDED = "SUCCEEDED"; // 执行成功
    public static final String STATUS_FAILED = "FAILED";      // 执行失败
    public static final String STATUS_UNKNOWN = "UNKNOWN";    // 任务不存在或状态未知

    public boolean isCompleted() {
        return STATUS_SUCCEEDED.equals(output.getTaskStatus()) || 
               STATUS_FAILED.equals(output.getTaskStatus());
    }

    public boolean isSuccessful() {
        return STATUS_SUCCEEDED.equals(output.getTaskStatus());
    }

    public boolean isFailed() {
        return STATUS_FAILED.equals(output.getTaskStatus());
    }

    public String getGeneratedVideoUrl() {
        return output != null && output.getResults() != null ? 
               output.getResults().getVideoUrl() : null;
    }
} 